package com.object.utils;

import com.object.module.lq.sys.entity.TRoleAuthorizationEntity;

import java.util.ArrayList;
import java.util.List;

/**
 * 权限 工具类
 */
public class RolePermissionUtil {

    /**
     * 将权限转换为对象集
     *
     * @param purviewS
     * @param reId
     * @return
     */
    public static List<TRoleAuthorizationEntity> ConvertPermissionToObjectSet(String[] purviewS, Integer reId) {

        List<TRoleAuthorizationEntity> list = new ArrayList<>();
        for (String purview : purviewS) {
            String[] split = purview.split(",");
            Integer rtId = Integer.valueOf(split[0]);
            String permission = split[1];
            TRoleAuthorizationEntity tRolePermission = new TRoleAuthorizationEntity();
            tRolePermission.setRtId(rtId);
            tRolePermission.setReId(reId);
            tRolePermission.setRaPermission(permission);
            list.add(tRolePermission);
        }
        return list;
    }
}
